package ar.camera.thread;

import java.io.IOException;
import java.net.Socket;

import android.os.Handler;
import android.os.Message;
import ar.globals.Globals;

public class ConnectServerThread implements Runnable{

	private Handler handler;
	
	public ConnectServerThread(Handler handler) {
		super();
		this.handler = handler;
	}

	@Override
	public void run() {
		try {
			Globals.client1Socket = new Socket(Globals.serverAddress, 3333);
			Globals.client2Socket = new Socket(Globals.serverAddress, 3333);
			Message msg = handler.obtainMessage(
					Globals.MSG_CONNECT_SUCCESSFULLY, null);
			handler.sendMessage(msg);
		} catch (IOException e) {
			e.printStackTrace();
			Message msg = handler.obtainMessage(
					Globals.MSG_CONNECT_FAILED, e.getMessage());
			handler.sendMessage(msg);
		}
	}

}


